<template>
	<view>
		<!-- <TopNavCustom :title="title"></TopNavCustom> -->
		<view class="content">
			<text class="time">{{time}}</text>
			<view class="add-zone">
				<view class="add-form">
					<u-cell-group :border="false">
						<u-cell size="normal" title="问题类别" :value="listData.faultName">
						</u-cell>
						<u-cell size="normal" v-if="listData.issuesType==2">
							<div slot='value'>{{getValue(listData.issueTags)}}</div>
						</u-cell>
						<u-cell size="normal" title="问题部位" :value="listData.issueLocation">
						</u-cell>
						<u-cell size="normal" title="问题处理人" :value="listData.handlerUserId">
						</u-cell>
						<u-cell size="normal" title="发现时间" :value="listData.discoveryTime"></u-cell>
						<u-cell size="normal" title="预计处理时间" :value="listData.estimatedProcessingTime">
						</u-cell>
						<u-cell size="normal" title="问题描述" :border="false"></u-cell>
						<view class="pixs">
							<textarea style="padding-left:30rpx ;" :value="listData.issuesDesc"
								placeholder="请描述问题，最多输入200个字" disabled />
						</view>
						<u-cell size="normal" title="现场情况" :border="false"></u-cell>
						<view class="pixs">
							<view v-for="(img,i) in listData.pixs" :key="i">
								<image :src="getSrc(img)" class="pix" @tap="previewImage1(i)"></image>
							</view>
						</view>
					</u-cell-group>
				</view>
			</view>
			<view class="add-zone" style="margin-top: 20rpx;">
				<view class="add-form">
					<u-cell-group :border="false">
						<u-cell size="normal" title="是否已整改：" :value="getStatus(listData.issuesStatus)">
						</u-cell>
						<u-cell size="normal" title="反馈描述" :border="false"></u-cell>
						<view class="pixs">
							<textarea style="padding-left:30rpx ;" :value="listData.feedBack"
								placeholder="请描述问题，最多输入200个字" disabled />
						</view>
						<u-cell size="normal" title="现场情况" :border="false"></u-cell>
						<view class="pixs">
							<view v-for="(img,i) in listData.pixs2" :key="i">
								<image :src="getSrc(img)" class="pix" @tap="previewImage2(i)"></image>
							</view>
						</view>
					</u-cell-group>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time: uni.$u.timeFormat(false, 'yyyy-mm-dd'),
				listData: {},
				title: "",
				temp: {}
			};
		},
		onLoad(params) {
			let temp = JSON.parse(decodeURIComponent(params.item))
			this.listData = temp
			this.title = temp.issueLocation
			if (typeof temp.issueImages == undefined || temp.issueImages == '') {
				this.listData.pixs = []
			} else {
				this.listData.pixs = temp.issueImages.split(',')
			}
			if (typeof temp.issueImages2 == undefined || temp.issueImages2 == '') {
				this.listData.pixs2 = []
			} else {
				this.listData.pixs2 = temp.issueImages2.split(',')
			}
			console.log(temp)
		},
		methods: {
			//预览轮播图
			previewImage1: function(index) {
				let pixSrcs = []
				for (let i = 0; i < this.listData.pixs.length; i++) {
					let element = this.getSrc(this.listData.pixs[i])
					pixSrcs.push(element)
				}
				//uniapp预览轮播图
				uni.previewImage({
					current: index, //预览图片的下标
					urls: pixSrcs //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			//预览轮播图
			previewImage2: function(index) {
				let pixSrcs = []
				for (let i = 0; i < this.listData.pixs2.length; i++) {
					let element = this.getSrc(this.listData.pixs2[i])
					pixSrcs.push(element)
				}
				//uniapp预览轮播图
				uni.previewImage({
					current: index, //预览图片的下标
					urls: pixSrcs //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
				})
			},
			getValue(value) {
				if (typeof value == undefined || value == null) {
					return ''
				} else {
					return value
				}
			},
			getSrc(id) {
				if ((typeof id) != undefined && id != '') {
					let _src = uni.$http.baseURL + '/file/download?fileId=' + id
					return _src
				}
			},
			getStatus(value) {
				switch (value) {
					case 3:
						return '是'
						break;
					default:
						return '否'
						break;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding: 20rpx 30rpx 58rpx 30rpx;
	}

	.add-zone {
		border: 1rpx solid #efefef;
		border-radius: 20rpx;
		background-color: #FFFFFF;
	}

	.add-form {
		display: flex;
		flex-direction: column;
		// padding: 30rpx 11rpx 6rpx 28rpx;
		margin-left: 30rpx;

		.pixs {
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			margin-top: 20rpx;

			.pix {
				width: 200rpx;
				height: 200rpx;
				margin-right: 10rpx;
				margin-bottom: 20rpx;
			}
		}
	}
</style>
